﻿using System.Collections.Generic;
using System.Linq;
using MySql.Data.MySqlClient;
using iRealtor.Maps.DataAccess.Models;
using iRealtor.Maps.DataAccess.Services;

namespace iRealtor.Maps.Core.Services
{
	public class GroupsService : MySQLBaseService
	{
		public Group GetGroup(int groupId)
		{
			var q = new MySqlCommand("select * from Groups where GroupId=@GroupId");
			q.Parameters.AddWithValue("@GroupId", groupId);

			var g = dao.Load<Group>(q).FirstOrDefault();
			return g;
		}

		public List<Group> GetGroups()
		{
			var q = new MySqlCommand("select * from Groups");
			var g = dao.Load<Group>(q).ToList();
			
			return g;
		}
	}
}
